-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Per output plugins #3218
Per output plugins #3218
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3218 +/- ##
==========================================
+ Coverage 90.64% 91.26% +0.62%
==========================================
Files 167 170 +3
Lines 5911 5922 +11
Branches 1793 1794 +1
==========================================
+ Hits 5358 5405 +47
+ Misses 336 311 -25
+ Partials 217 206 -11
Continue to review full report at Codecov.
|
That's wonderful—I needed exactly that earlier today. Thanks for doing this work! |
From what I can see this can hook into rendering, but I'm not sure what rendering is - is tree-shaking process? from the prepared input graph to the output one? I'm wondering if this would allow me to in example build 2 bundles with process.env.NODE_ENV replaced to "production" and "development" in a single config. |
Output plugins act only after tree-shaking and chunking are done. Basically what you can do is transform the emitted chunks, add banners/footers etc. Changing the tree-shaking between outputs would basically mean we need to repeat a lot between outputs and would mostly prevent the possible performance gains. |
221b1c3
to
6931b4f
Compare
…per-output plugins TODO: Add phases (build/generate) to hooks in documentation TODO: Think about creating an Output interface containing options, driver, bundle?
6931b4f
to
1b84fda
Compare
a18d8dc
to
5869d10
Compare
5869d10
to
a3a2315
Compare
Thanks Lukas this is an amazing feature 🎉 |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #3174
Resolves #3098
Description
This is the new big feature I have been working on. It will solve the issues of files emitted from different outputs overwriting each other by giving each output a separate FileEmitter, but more importantly, this will allow different outputs to have different plugins.
Example how this is useful:
The big advantage is that you can now generate a minified and a non-minified build together without needing to repeat the analysis step, which will be noticeably faster than run rollup twice.
Rules for output plugins:
options
hook.renderStart
hook will now receive two arguments:outputOptions
andinputOptions
.This is a draft PR as it still lacks any documentation. However, it should be fully useable and I invite everyone to test it via
npm i rollup/rollup#per-output-plugins
.cc @marijnh